package org.example;

import java.math.BigDecimal;
import java.math.RoundingMode;

public class Main {
    public static void main(String[] args) throws Exception {
        Calculator calculator = new Calculator();
        //两个数字
        BigDecimal num1 = new BigDecimal("1");
        BigDecimal num2 = new BigDecimal("2");

        //通过 calculator 进行加减乘除操作
        calculator.add(num1, num2)
                .add(new BigDecimal("3"))
                .add(BigDecimal.TEN).
                subtract(BigDecimal.ONE)
                .multiply(new BigDecimal("5.5"))
                .divide(new BigDecimal("3"), RoundingMode.HALF_UP)
        ;

        //获取redo日志
        calculator.redoList();
        //获取undo日志
        calculator.undoList();

        System.out.println("flags = " + calculator.getFlags());
        System.out.println("redo后数据：" + calculator.redo(1));
        System.out.println("flags = " + calculator.getFlags());
        System.out.println("undo 3 位后数据：" + calculator.undo(3));
        System.out.println("flags = " + calculator.getFlags());
        System.out.println("redo后数据：" + calculator.redo(1));
        System.out.println("redo后数据：" + calculator.redo(1));
        System.out.println("redo后数据：" + calculator.redo(1));
        System.out.println("redo后数据：" + calculator.redo(1));
        System.out.println("undo后数据：" + calculator.undo(1));
        System.out.println("undo后数据：" + calculator.undo(1));
        System.out.println("undo后数据：" + calculator.undo(1));
        System.out.println("undo后数据：" + calculator.undo(1));
        System.out.println("undo后数据：" + calculator.undo(1));
        System.out.println("undo后数据：" + calculator.undo(1));
        System.out.println("undo后数据：" + calculator.undo(1));
        System.out.println("flags = " + calculator.getFlags());
        System.out.println("redo后数据：" + calculator.redo(1));
//        calculator.add(new BigDecimal(2));
//        System.out.println("undo后数据：" + calculator.undo(10));
        System.out.println("当前数据 = " + calculator.getFinalResult().getFinalResult());
    }
}